package sk.ygor.raynor.client.json.basetype;

import com.google.gwt.json.client.JSONBoolean;
import com.google.gwt.json.client.JSONValue;
import sk.ygor.raynor.client.json.JSONSerializationException;

public class java_lang_Boolean_JSONSerializer extends BaseTypeSerializer<Boolean> {

    @Override
    protected Boolean deserializeNonNullValue(JSONValue jsonValue) {
        JSONBoolean bool = jsonValue.isBoolean();
        if (bool != null) {
            return bool.booleanValue();
        }
        throw new JSONSerializationException("Cannot create Long from: " + jsonValue);
    }

    @Override
    protected JSONValue serializeNonNullValue(Boolean javaValue) {
        return JSONBoolean.getInstance(javaValue);
    }

}